package cn.com.action;

import java.util.List;
import java.util.Map;

import org.apache.struts2.interceptor.SessionAware;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import com.opensymphony.xwork2.ActionSupport;

import cn.com.biz.YuYueBiz;
import cn.com.entity.YuYue;

public class YuYueAction extends ActionSupport implements SessionAware{
	Map<String, Object> session;
	
	public Map<String, Object> getSession() {
		return session;
	}

	@Override
	public void setSession(Map<String, Object> arg0) {
		session=arg0;
	}

	private YuYueBiz yuyueBiz;
	private YuYue yuyue;
	private int id;
	private int userid;
	private int yishengid;
	
	public int getUserid() {
		return userid;
	}

	public void setUserid(int userid) {
		this.userid = userid;
	}

	public int getYishengid() {
		return yishengid;
	}

	public void setYishengid(int yishengid) {
		this.yishengid = yishengid;
	}

	public int getId() {
		return id;
	}

	public void setId(int id) {
		this.id = id;
	}

	public YuYueBiz getYuyueBiz() {
		return yuyueBiz;
	}

	public void setYuyueBiz(YuYueBiz yuyueBiz) {
		this.yuyueBiz = yuyueBiz;
	}
	
	public YuYue getYuyue() {
		return yuyue;
	}

	public void setYuyue(YuYue yuyue) {
		this.yuyue = yuyue;
	}

	public String ckyuyue(){
		ApplicationContext ctx=new ClassPathXmlApplicationContext("applicationContext.xml");
		yuyueBiz=(YuYueBiz)ctx.getBean("yuyueBiz");
		List<YuYue> yylist=yuyueBiz.ckyuyue();
		if(yylist!=null){
			session.put("yylist", yylist);
			return SUCCESS;
		}else{
			return ERROR;
		}
	}
	public String insertyuyue(){
		boolean b=yuyueBiz.insertyuyue(yuyue);
		if(b){
			return "tianjiachenggong";
		}else{
			return "tianjiashibai";
		}
	}
	public String deletekeshi(){
		boolean b=yuyueBiz.deleteyuyue(id);
		if(b){
			return "shanchuchenggong";
		}else{
			return "shanchushibai";
		}
	}
	public String getuserid(){
		List<YuYue> yhlist=yuyueBiz.getuserid(userid);
		if(yhlist!=null){
			session.put("yhlist", yhlist);
			return SUCCESS;
		}else{
			return ERROR;
		}
	}
	public String getyishengid(){
		List<YuYue> yslist=yuyueBiz.getuserid(yishengid);
		if(yslist!=null){
			session.put("yslist", yslist);
			return SUCCESS;
		}else{
			return ERROR;
		}
	}	
	
}
